const path = require("path");
const { paths } = require("react-app-rewired");
const {
    override,
    fixBabelImports,
    addPostcssPlugins,
    useEslintRc,
    addWebpackAlias
} = require("customize-cra");

module.exports = override(
    fixBabelImports("import", {
        libraryName: "antd",
        libraryDirectory: "es",
        style: 'css'
    }),
    useEslintRc(),
    addPostcssPlugins([
        require('postcss-import'),
        require('precss'),
        require('cssnano'),
        require('cssnext'),
        require('autoprefixer')(),
        require('postcss-flexbugs-fixes')
    ]),
    addWebpackAlias({
        "assets": path.resolve(__dirname, `${paths.appSrc}/assets`),
        "axios": path.resolve(__dirname, `${paths.appSrc}/axios`),
        "components": path.resolve(__dirname, `${paths.appSrc}/components`),
        "config": path.resolve(__dirname, `${paths.appSrc}/config`),
        "pages": path.resolve(__dirname, `${paths.appSrc}/pages`),
        "routes": path.resolve(__dirname, `${paths.appSrc}/routes`),
        "services": path.resolve(__dirname, `${paths.appSrc}/services`),
        "utils": path.resolve(__dirname, `${paths.appSrc}/utils`)
    })
);
